﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Sinacor.OMM.HealthMonitor.Entity.Dumper;

namespace Sinacor.OMM.HealthMonitor.Collector.SharedHealthDataMemoryStorage.Dumper
{
    [Serializable]
    public class DumperShdms : IDisposable
    {
        private static DumperShdms _dumperShmds;
        private static Mutex mtx = new Mutex();

        private DumperShdms()
        {

        }

        public static DumperShdms GetSharedStorage()
        {
            mtx.WaitOne();
            if (_dumperShmds == null)
            {
                _dumperShmds = new DumperShdms();
            }
            mtx.ReleaseMutex();

            return _dumperShmds;
        }

        private DumperData _dumperData;
        public DumperData DumperDataInfo
        {
            get
            {
                if (_dumperData == null)
                    _dumperData = new DumperData();

                return _dumperData;
            }
        }

        #region IDisposable Members

        public void Dispose()
        {
            _dumperShmds = null;
            mtx.Close();
            _dumperData = null;
        }

        #endregion
    }
}
